/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Dotke
 */
@Entity
@Table(name = "BILLER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Biller.findAll", query = "SELECT b FROM Biller b"),
    @NamedQuery(name = "Biller.findByBillerId", query = "SELECT b FROM Biller b WHERE b.billerId = :billerId"),
    @NamedQuery(name = "Biller.findByBillerName", query = "SELECT b FROM Biller b WHERE b.billerName = :billerName")})
public class Biller implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "BILLER_ID")
    private Integer billerId;
    @Column(name = "BILLER_NAME")
    private String billerName;
    @JoinColumn(name = "BILLER_ACCOUNT_ID", referencedColumnName = "ACCOUNT_ID")
    @ManyToOne(optional = false)
    private Account billerAccountId;
    @OneToMany(mappedBy = "accountBillerId")
    private Collection<Account> accountCollection;

    public Biller() {
    }

    public Biller(Integer billerId) {
        this.billerId = billerId;
    }

    public Integer getBillerId() {
        return billerId;
    }

    public void setBillerId(Integer billerId) {
        this.billerId = billerId;
    }

    public String getBillerName() {
        return billerName;
    }

    public void setBillerName(String billerName) {
        this.billerName = billerName;
    }

    public Account getBillerAccountId() {
        return billerAccountId;
    }

    public void setBillerAccountId(Account billerAccountId) {
        this.billerAccountId = billerAccountId;
    }

    @XmlTransient
    public Collection<Account> getAccountCollection() {
        return accountCollection;
    }

    public void setAccountCollection(Collection<Account> accountCollection) {
        this.accountCollection = accountCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (billerId != null ? billerId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Biller)) {
            return false;
        }
        Biller other = (Biller) object;
        if ((this.billerId == null && other.billerId != null) || (this.billerId != null && !this.billerId.equals(other.billerId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.entity.Biller[ billerId=" + billerId + " ]";
    }
    
}
